<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加用户</title>
    <script src="/static/js/jquery.min.js"></script>
</head>
<body>

<form method="post">
    <label>
        <input type="text" name="username" id="username">
    </label>

    <button id="submit" name="submit" type="button">添加</button>
</form>
<a href="userList.html">用户列表</a>
<script type="text/javascript">
    //使用jQuery完成
    $(document).ready(function(){
        $("#submit").click(function(){
            //jQuery.ajax({})方法完成异步请求
            $.ajax({
                url: "../../../user/add", //请求路径urlPattern
                dataType: "text",
                type: "post",
                data: {
                    username: $("#username").val(),
                    birth: $("#birth").val()
                },
                success: function(){
                    window.location.href='userList.html'
                }
            });
        });
    });
</script>
</body>
</html>